﻿module Lhz.Entity.ServiceCenter {
    export class Authorization extends DbEntity {
        UserGuid: string;
        User: User;
        ObjectGuid: string;
        AuthorizationType: number;
        Application: Application;
        Service: Service;
        Operation: Operation;
        static GetObjectName(authorization: Authorization): string {
            var ao: DbEntity = null;
            switch (authorization.AuthorizationType) {
                case 0:
                    ao = authorization.Application;
                    break;
                case 1:
                    ao = authorization.Service;
                    break;
                case 2:
                    ao = authorization.Operation;
                    break;
                default:
                    ao = null;
                    break;
            }
            if (ao == null) {
                return null;
            }
            else {
                return ao["Name"];
            }
        }
    }
}
